<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class BaseController extends Controller
{
	/**
	 * @var string the default layout for the controller view. Defaults to '//layouts/column1',
	 * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
	 */
	public $layout='//layouts/column2';
	/**
	 * @var array context menu items. This property will be assigned to {@link CMenu::items}.
	 */
	public $menu=array();
	
	public $rightCode = '';
	/**
	 * @var array the breadcrumbs of the current page. The value of this property will
	 * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
	 * for more details on how to specify this property.
	 */
	public $breadcrumbs=array();
	
	public $leftmenusTitle='常用操作';
	public $leftmenus=array(
		  array('href'=>'#','menutext'=>'常用操作一',),
		  array('href'=>'#','menutext'=>'常用操作一',),
		  array('href'=>'#','menutext'=>'常用操作一',),
		  array('href'=>'#','menutext'=>'常用操作一',),
		  array('href'=>'#','menutext'=>'常用操作一',),
	    );
	
	public $title = '内容';
	
	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
		);
	}

		/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules()
	{
		return array(
			array('allow', // allow authenticated users to access all actions
				'users'=>array('@'),
			),
			array('deny',  // deny all users
				'users'=>array('*'),
			),
		);
	}
	/**
	 * 子功能首页
	 */
	public function actionIndex()
	{
		$hasFlag = false;
		foreach($this->leftmenus as $value)
		{
			if($value['isValid'])
			{
				$this->redirect($value['href']);
				$hasFlag = true;
			}
		}
		if(!$hasFlag)
		{
			$this->render('valid');
		}
		
	}
	
	protected function beforeAction()
	{	
		if(!isset(Yii::app()->session['currenUser'])&&isset(Yii::app()->user->id))
		{
			Yii::app()->session['currenUser'] = User::model()->findByStaffId(Yii::app()->user->id);
		}
	}
	
}